from multiprocessing import Process, Lock, Array

def f(l, i):
    #l.acquire()  # 上锁
    try:
        i[0] += 1
    finally:
        #l.release()  # 释放锁
        pass

if __name__ == '__main__':
    lock = Lock()
    array = Array("i", 1)
    array[0] = 0
    for i in range(10):
        process = Process(target=f, args=(lock, array))
        process.start()
        process.join()
    print(array[0])  # 同步之后一定是10
